package com.ai.tcc.order.controller;

import com.ai.tcc.order.model.TccOrder;
import com.ai.tcc.order.service.OrderService;
import org.redisson.api.RBucket;
import org.redisson.api.RedissonClient;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * Date:  2018/10/30
 * Time:  13:46
 * Email: siy@hmgsoft.com
 * Created by siy
 */
@RequestMapping("/v1")
@RestController
public class OrderController {

    @Resource
    private OrderService orderService;
    @Resource
    private RedissonClient redissonClient;

    @PostMapping("/sel")
    public String sel(@RequestBody TccOrder order){
        TccOrder rs = orderService.select(order);
        if(rs==null){
            return "notFound";
        }
        return rs.toString();
    }

    @PostMapping("/add")
    public String add(@RequestBody TccOrder order){
        orderService.add(order);
        return "ok";
    }

    @GetMapping("/rAdd")
    public String rAdd(){
        RBucket<String> keyObject = redissonClient.getBucket("key");
        keyObject.set("value");
        return "ok";
    }

}
